<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix" style="height: 32px">
        <el-row align="middle" type="flex">
          <el-col>
            <span v-if="title">{{ title + "  -  " }}</span>
            <span>提交列表</span>
          </el-col>
        </el-row>
      </div>

      <div>
        <el-table
          :height="tableHeight"
          :max-height="tableHeight"
          :data="tableData"
          border
          style="width: 100%">

          <el-table-column
            align="center"
            prop="stuId"
            label="学号">
          </el-table-column>

          <el-table-column
            align="center"
            prop="stuName"
            label="姓名">
          </el-table-column>

          <el-table-column
            align="center"
            prop="submitTime"
            label="提交次数">
          </el-table-column>

          <el-table-column
            align="center"
            prop="score"
            label="得分">
          </el-table-column>

          <el-table-column
            align="center"
            label="操作">
            <template slot-scope="{ row }">
              <el-link type="primary" @click="stuEvalItem(row)">详情</el-link>
            </template>
          </el-table-column>

        </el-table>
      </div>
    </el-card>
  </div>
</template>

<script>

import {SubmitItemList} from "@/api/bt/student-eval/check/submit-list";

export default {
  name: "SubmitList",
  data() {
    return {
      //表格高度根据窗口
      tableHeight: window.innerHeight - 220,
      screenHeight: window.innerHeight,
      // 表格数据
      tableData: [],
      title: undefined,
    }
  },
  mounted() {
    const that = this
    window.onresize = () => {
      return (() => {
        window.screenHeight = window.innerHeight
        this.screenHeight = window.screenHeight;
      })()
    }
  },
  watch: {
    screenHeight(val) {
      this.screenHeight = val
      this.tableHeight = this.screenHeight - 220
    }
  },
  methods: {
    init(row, clazzId) {
      this.title = row.name
      this.SubmitItem(row.id, clazzId);
    },
    SubmitItem(itemId, clazzId) {
      SubmitItemList(itemId, clazzId).then((res) => {
        this.tableData = res.data
      })
    },
    stuEvalItem(row) {
      this.$emit("stu-eval", row)
    },
  },
}
</script>

<style scoped>
::v-deep.el-table--border {
  border-bottom: 1px solid #EBEEF5;
}
</style>
